using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace TriUan.TriUanGameComponent.GameComponents
{
    public class RectangleRangeLimited : IRangeLimited
    {
        public RectangleRangeLimited()
        {
        }

        public bool CheckRange(List<Vector2> vertices, Vector2 position)
        {
            bool result = false;
	        for(int i = 0, j = vertices.Count-1; i < vertices.Count; j = i++)
	        {
		        if( ((vertices[i].Y > position.Y ) != (vertices[j].Y > position.Y)) &&
			        ( position.X < (vertices[j].X - vertices[i].X ) * (position.Y - vertices[i].Y) / (vertices[j].Y - vertices[i].Y) + vertices[i].X ))
                    result = !result;
	        }
            return result;
        }

        public void Update(Vector2 position)
        {
//             this.boundRect.X = (int)position.X;
//             this.boundRect.Y = (int)position.Y;
        }
    }
}
